package org.deadline.service.baseapp;

import java.util.List;
import org.deadline.model.baseapp.EmailNotification;
import org.deadline.repository.baseapp.EmailNotificationRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


@Service
@Transactional
public class EmailNotificationServiceImpl implements EmailNotificationService {

	@Autowired
    EmailNotificationRepository emailNotificationRepository;

	public long countAllEmailNotifications() {
        return emailNotificationRepository.count();
    }

	public void deleteEmailNotification(EmailNotification emailNotification) {
        emailNotificationRepository.delete(emailNotification);
    }

	public EmailNotification findEmailNotification(Long id) {
        return emailNotificationRepository.findOne(id);
    }

	public List<EmailNotification> findAllEmailNotifications() {
        return emailNotificationRepository.findAll();
    }

	public List<EmailNotification> findEmailNotificationEntries(int firstResult, int maxResults) {
        return emailNotificationRepository.findAll(new org.springframework.data.domain.PageRequest(firstResult / maxResults, maxResults)).getContent();
    }

	public void saveEmailNotification(EmailNotification emailNotification) {
        emailNotificationRepository.save(emailNotification);
    }

	public EmailNotification updateEmailNotification(EmailNotification emailNotification) {
        return emailNotificationRepository.save(emailNotification);
    }
}
